#!/bin/bash
# kill api
echo "【api】"
sp_pid1=`ps -ef | grep api-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}'`
if [ -z "$sp_pid1" ];
then
  echo "[ api are not running ]"
else
  ps -ef | grep api-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}' | xargs kill -9
  echo "[ api are running, found pid number is $sp_pid1, now its process has been killed ]"
fi
# kill gateway
echo "【gateway】"
sp_pid2=`ps -ef | grep gateway-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}'`
if [ -z "$sp_pid2" ];
then
  echo "[ gateway are not running ]"
else
  ps -ef | grep gateway-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}' | xargs kill -9
  echo "[ gateway are running, found pid number is $sp_pid2, now its process has been killed ]"
fi
# kill auth
echo "【auth】"
sp_pid3=`ps -ef | grep auth-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}'`
if [ -z "$sp_pid3" ];
then
  echo "[ auth are not running ]"
else
  ps -ef | grep auth-1.0.jar | grep -v grep | grep -w ${USER} | awk '{print $2}' | xargs kill -9
  echo "[ auth are running, found pid number is $sp_pid3, now its process has been killed ]"
fi